<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			window.onload=function(){
				var btns=document.querySelectorAll('button');
				for(let i=0; i<btns.length; i++){
					btns[i].onclick=function(){
						alert('这是第'+(i+1)+'个按钮！')
					}
				}
			}
		</script>
	</head>
	<body>
		<button>按钮1</button>
		<button>按钮2</button>
		<button>按钮3</button>
		<button>按钮4</button>
	</body>
</html>
